<template>
  <div>
    <el-dropdown @command="languageToggle">
      <span style="color: #fff">
        <svg-icon icon-class="language" />
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item command="en">English</el-dropdown-item>
          <el-dropdown-item command="zh">中文</el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>
<script>
import cookieJs from 'js-cookie'
export default {
  name: 'Lang',
  inject: ['reload'],
  methods: {
    languageToggle(command) {
      this.$i18n.locale = command
      this.reload()
      cookieJs.set('lang', command)
    }
  }
}
</script>
<style scoped lang="scss"></style>
